<!DOCTYPE html>
<html>
<head>
    <title>寡王系统 v1.0</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="css/style.css" type="text/css" media="all" />
</head>
<body>
    <div class="signinform">
        <h1>寡王系统 v1.0</h1>
        <!-- container -->
        <div class="container">
            <!-- main content -->
            <div class="w3l-form-info">
                <div class="w3_info">
                    <h2>输入信息</h2>
                    <form>
                        <div class="input-group">
                            <span><i class="fas fa-user" aria-hidden="true"></i></span>
                            <input type="text" class="name" name="name" placeholder="他/她的姓名">
                        </div>
                       <div class="input-group">
                           <span><i class="fas fa-phone" aria-hidden="true"></i></span>
                           <input type="text" class="phoneNumber" name="phoneNumber" placeholder="他/她的号码">
                       </div>
					   <div class="input-group">
					       <span><i class="fas fa-city" aria-hidden="true"></i></span>
					       <input type="text" class="city" name="city" placeholder="他/她的城市">
					   </div>
                        
                        <button class="btn btn-primary btn-block" type="button" onclick="start()">开始执行任务</button>
                    </form>
                    <p class="continue"><span>超级寡王系统</span></p>
                    
                    <p class="account">不会使用? <a href="javascript:alert('憨批，按提示输入，然后点开始')">点击查看规则</a></p>
                </div>
            </div>
        </div>
        <div class="footer">
            <p>&copy; 2021 伟杰老师公开课网页模板 | 微信公众号 <a href="https://itdage.cn/images/gg4.jpg"
                    target="blank">itdage</a></p>
        </div>
    </div>
    <script src="js/fontawesome.js"></script>
    <script>
        function start(){
                let xhr=new XMLHttpRequest();
                let name = document.querySelector(".name").value;
                let phoneNumber = document.querySelector(".phoneNumber").value;
                let city = document.querySelector(".city").value;
                xhr.open('GET','start?name='+name+'&phoneNumber='+phoneNumber+'&city='+city,true);
                xhr.onreadystatechange=function(){
                    // readyState == 4说明请求已完成
                    if(xhr.readyState==4){
                        if(xhr.status==200 || xhr.status==304){
                            let data = JSON.parse(xhr.responseText);
                            if(data.status == 0){
                                setTimeout(function(){
                                    alert("启动成功，点击跳转数据页");
                                    window.location.href = "index.html";
                                },1500)
                            }else{
                                alert("启动失败，可能正在执行其他任务");
                            }
                        }
                    }
                }
                xhr.send();
                alert("正在启动任务...");
        }
    </script>
</body>

</html>